package com.cwj.mansysback.servlet.impl;

import com.cwj.mansysback.entity.Account;
import com.cwj.mansysback.entity.Rank;
import com.cwj.mansysback.entity.Teacher;
import com.cwj.mansysback.servlet.util.MyUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;

public class GetALLRankServlet extends HttpServlet {

    class GetRankStatement extends Statement{
        HashMap<String, Rank> ranks;

        public GetRankStatement(Integer statue) {
            super(statue);
        }

        public HashMap<String, Rank> getRanks() {
            return ranks;
        }

        public void setRanks(HashMap<String, Rank> ranks) {
            this.ranks = ranks;
        }
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        GetRankStatement statement = new GetRankStatement(8);

        if(req.getRequestURI().contains("/Lock/GetALLRank")){
            statement.setStatue(0);
            statement.setRanks(Teacher.getTeaRankNames());
        }

        MyUtils.writeResponse(resp,statement);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
